import BaseController from '../../core/controllers/Base.controller';

@Inject('$log', '$rootScope', 'noticeService', 'ngDialog', 'ngDialogService')
class NoticeInfoController extends BaseController {
  constructor() {
    super();

    this.paginationService = this.noticeService;
    this.$setQueryCallback((res) => {
      this.noticeListData = res.rows;
    });

    this.mapParams = {};

    this.$paginationQuery();
  }

  $reset() {
    this.mapParams = {};
  }

  $delete(id) {
    this.ngDialogService.confirm('确定删除此数据吗？', id)
      .then((data) => {
        this.noticeService
          .delete([id])
          .then((res) => {
            if (res.success) {
              this.ngDialogService.alertSuccess(res.message);
              this.$paginationQuery();
            }
          });
      });
  }
}

export default NoticeInfoController;
